<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('shops', function (Blueprint $table) {
            $table->id();
            $table->string('name')->comment('商品名称');
            $table->string('url')->comment('商品图片url');
            $table->text('description')->nullable()->comment('商品描述');
            $table->decimal('price', 10, 2)->comment('商品价格');
            // $table->decimal('rate', 10, 2)->comment('中奖概率');
            $table->foreignId('admin_id')->constrained('admins', 'id', 'admin_id')->onDelete('cascade');
            $table->foreignId('norm_id')->nullable()->constrained('norms', 'id', 'norm_id')->onDelete('cascade');
            $table->unsignedInteger('stock_quantity')->comment('商品库存');
            $table->foreignId('shop_cate_id')->constrained('shop_cates', 'id', 'shop_cate_id')->onDelete('cascade')->comment('商品分类ID');
            $table->unsignedInteger('order')->default(0)->comment('排序');
            $table->tinyInteger('hidden')->default(1)->comment('0:false/1:true');
            $table->string('status')->default('1')->comment('商品状态 1/正常 0/禁用');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('shops');
    }
};
